package com.fwtai.web;

import com.fwtai.bean.PageFormData;
import com.fwtai.datasource.DaoHandle;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;

/**
 * 积分商城的订单访问数据库
 * @作者 田应平
 * @版本 v1.0
 * @创建时间 2024-02-20 14:14:19
 * @QQ号码 444141300
 * @Email service@fwtai.com
 * @官网 <url>http://www.fwtai.com</url>
*/
@Repository
public class MallOrderInfoDao{

  private final DaoHandle dao;

  public MallOrderInfoDao(final DaoHandle dao){
    this.dao = dao;
  }

  @Transactional
  public int addLogistics(final PageFormData formData,final long out_trade_no){
    final int rows = dao.execute("mall_order_info.updateComplete",out_trade_no);
    if(rows > 0){
      dao.execute("mall_order_info.addOrderLogistics",formData);
    }
    return rows;
  }

  public int editLogistics(final PageFormData formData){
    return dao.execute("mall_order_info.editLogistics",formData);
  }

  public Long queryExistById(final long kid){
    return dao.queryForLong("mall_order_info.queryExistById",kid);
  }

  public HashMap<String,Object> queryById(final long out_trade_no){
    return dao.queryForHashMap("mall_order_info.queryById",out_trade_no);
  }

  public List<HashMap<String,Object>> getListData(final PageFormData formData){
    return dao.queryForListHashMap("mall_order_info.listData",formData);
  }

  public Integer getListTotal(final PageFormData formData){
    return dao.queryForInteger("mall_order_info.listTotal",formData);
  }
}